package vip.zhenzicheng.jvm.jvmbook.part2;

/**
 * 测试栈内存溢出 StackOverflowError
 * VM Args：-Xss128k
 *
 * @author zhenzicheng
 * @date 2022-07-15 17:53
 */
public class JavaVMStackSOF {

  private int stackLength = 1;

  public void stackLeak() {
    stackLength++;
    stackLeak();
  }

  public static void main(String[] args) {
    JavaVMStackSOF oom = new JavaVMStackSOF();
    try {
      oom.stackLeak();
    } catch (Throwable e) {
      System.out.println("stack length:" + oom.stackLength);
      throw e;
    }
  }
}
